package mortal.game.control
{
	import Message.BroadCast.*;
	import Message.Game.*;
	import Message.Public.*;
	
	import com.gengine.utils.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.utils.*;
	
	import mortal.common.global.*;
	import mortal.common.sound.*;
	import mortal.component.gconst.*;
	import mortal.game.*;
	import mortal.game.cache.*;
	import mortal.game.events.*;
	import mortal.game.manager.*;
	import mortal.game.mvc.*;
	import mortal.game.resource.*;
	import mortal.game.resource.info.*;
	import mortal.game.rules.*;
	import mortal.game.scene.map.*;
	import mortal.game.scene.player.*;
	import mortal.game.view.common.*;
	import mortal.game.view.mainUI.*;
	import mortal.mvc.core.*;
	import mortal.mvc.interfaces.*;

	public class GameUIController extends Controller
	{
		private var _gameui:GameUI;
		
		public function GameUIController()
		{
			
		}
		
		override protected function initView() : IView
		{
			if (_gameui == null)
			{
				_gameui = new GameUI();
				this._gameui.addEventListener(MouseEvent.CLICK, this.onGameUIClickHandler);
				LayerManager.uiLayer.addChild(this._gameui);
				GameController.chat.view.show();
				GameController.taskTrack.view.show();
				this._gameui.addShortcuts((GameController.shortcuts.view as DisplayObject));
			}
			
			return _gameui;
		}
		
		private function onGameUIClickHandler(e:MouseEvent) : void
		{
			var button:SimpleButton = (e.target as SimpleButton);
			if (button){
				this._gameui.guideHideTips(button.name);
				GameManager.instance.popupWindow(button.name);
			}
		}
	}
}